package cn.zhf.shop.controller;

import cn.zhf.shop.entity.Message;
import cn.zhf.shop.entity.lesson.LessonType;
import cn.zhf.shop.entity.organization.OrganizationType;
import cn.zhf.shop.service.LessonTypeService;
import cn.zhf.shop.service.OrganizationTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "课程类别管理")
@RequestMapping("/api/lesson/types")
public class LessonTypeController {
    @Resource
    private LessonTypeService lessonTypeService;

    @ApiOperation(value = "获取列表")
    @GetMapping("/all")
    public Message<List<LessonType>> getAll(){
        return lessonTypeService.getAll();
    }

    @ApiOperation(value = "添加")
    @PostMapping("/append")
    public Message appendOrgType(LessonType orgType){
        return lessonTypeService.insert(orgType);
    }

    @ApiOperation(value = "删除")
    @PostMapping("/remove")
    public Message removeOrgType(int typeId){
        return lessonTypeService.deleteByPrimaryKey(typeId);
    }

    @ApiOperation(value = "更新")
    @PostMapping("/update")
    public Message updateOrgType(LessonType orgType){
        return lessonTypeService.updateByPrimaryKey(orgType);
    }

    @ApiOperation(value = "详情")
    @GetMapping("/")
    public Message<LessonType> get(int typeId){
        return lessonTypeService.selectByPrimaryKey(typeId);
    }

    @ApiOperation(value = "H5获取列表")
    @GetMapping("/H5/all")
    public Message<List<LessonType>> H5getAll(){
        return lessonTypeService.H5getAll();
    }



}
